package com.wshl.aijiuunion.utils.share;

import android.app.Activity;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;

import com.wshl.aijiuunion.GlobConstant;
import com.wshl.aijiuunion.HomeActivity;
import com.wshl.aijiuunion.controller.activity.LoginActivity;
import com.wshl.aijiuunion.view.bean.EventBeans;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by Administrator on 2018/10/18.
 */

public class LoginOutUtils {

    //重新登陆(应用场景:token错误或者token失效)
    public static void reLogin(Activity context) {

        SPUtils.getInstance().put(GlobConstant.ISSTARTMIAN, false);
        SPUtils.getInstance().put(GlobConstant.TOKEN, "");
        ToastUtils.showLong("请登录");

        ActivityUtils.startActivity(context, LoginActivity.class);


    }


    //退出登录
    public static void loginout(Activity context) {

        String mobile = SPUtils.getInstance().getString(GlobConstant.MOBILE);
        //点击确定按钮
        SPUtils.getInstance().clear();
        SPUtils.getInstance().put(GlobConstant.ISSTARTMIAN, true);
        SPUtils.getInstance().put(GlobConstant.MOBILE, mobile);
        EventBus.getDefault().post(new EventBeans(GlobConstant.FINISHACLLACTIVITY));
        ActivityUtils.startActivity(context, HomeActivity.class);
    }


}
